package com.vancouver.knows.business.service.impl;

import java.util.List;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.pangu.util.StringUtil;
import com.vancouver.knows.business.bean.BusinessImageInfo;
import com.vancouver.knows.business.bean.BusinessInfo;
import com.vancouver.knows.business.bean.CityDiscountDetailInfo;
import com.vancouver.knows.business.bean.CommentInfo;
/**
 * 查询城惠详情解析
 * <p/>
 * Created by cxlin
 */
public class FetchDiscountDetailHandler extends ACheckableJsonParser {

	private CityDiscountDetailInfo diacountDetailInfo;

	@Override
	protected void parserContent(JSONObject content) throws Exception {
		String posts = content.getString("business_details");
		diacountDetailInfo = JSON.parseObject(posts, CityDiscountDetailInfo.class);
		String hotComments = content.getString("hot_comments");
		if (!StringUtil.isEmptyString(hotComments)) {
			List<CommentInfo> commentInfoList = JSON.parseArray(hotComments, CommentInfo.class);
			diacountDetailInfo.setCommentInfoList(commentInfoList);
		}
		String suggestedBusiness = content.getString("suggested_business");
		if (!StringUtil.isEmptyString(suggestedBusiness)) {
			List<BusinessInfo> businessInfoList = JSON.parseArray(suggestedBusiness, BusinessInfo.class);
			diacountDetailInfo.setBusinessInfoList(businessInfoList);
		}
		String userImages = content.getString("user_images_array");
		if (!StringUtil.isEmptyString(userImages)) {
			List<BusinessImageInfo> businessImageInfoList = JSON.parseArray(userImages, BusinessImageInfo.class);
			diacountDetailInfo.setBusinessUserImages(businessImageInfoList);
		}

	}

	public CityDiscountDetailInfo getDiacountDetailInfo() {
		return diacountDetailInfo;
	}

}
